package com.vancouver.knows.business.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.pangu.util.StringUtil;
import com.vancouver.knows.business.bean.CityNewsInfo;

/**
 * 查询城事列表解析
 * <p/>
 * Created by cxlin
 */
public class FetchCityNewsHandler extends ACheckableJsonParser {

	public static final String KEY_POSTS = "posts";
	public static final String KEY_AD_POSTS = "ad_posts";

	private HashMap<String, Object> resultMap = new HashMap<String, Object>();

	@Override
	protected void parserContent(JSONObject content) throws Exception {
		JSONObject data = content.getJSONObject("data");
		String posts = data.getString("posts");
		if (StringUtil.isEmptyString(posts)) {
			resultMap.put(KEY_POSTS, new ArrayList<CityNewsInfo>());
			return;
		}

		List<CityNewsInfo> cityNewsInfoList = JSON.parseArray(posts, CityNewsInfo.class);
		resultMap.put(KEY_POSTS, cityNewsInfoList);
	}

	public HashMap<String, Object> getResultMap() {
		return resultMap;
	}
}
